package com.ymatou.iapi.optrade.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.optrade.parameter.req.AsyncNotifyReq;
import com.ymatou.iapi.optrade.resp.TradingServiceResp;
import com.ymatou.iapi.optrade.service.OrderAsyncNotifyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.YMTTrading.TradingCallService;
import com.ymttest.business.service.YMTTrading.TradingPlaceOrderCallService;
/**
*订单通知处理
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_OrderAsyncNotify {
	private static AsyncNotifyReq asyncNotifyReq;
	private static OrderAsyncNotifyCall orderAsyncNotifyCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("订单通知处理");
	}

	@Before
	public void caseUp() {
		asyncNotifyReq = new AsyncNotifyReq();
		orderAsyncNotifyCall = new OrderAsyncNotifyCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(orderAsyncNotifyCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderAsyncNotify_001() {
		Logger.start(true, "订单支付通知,标示新老客,2W限额校验");

		try {
			TradingServiceResp placeOrderResp = TradingCallService.payOrder();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			asyncNotifyReq.setBusinessType(2);

			asyncNotifyReq.setOrderId(orderId);

			orderAsyncNotifyCall.setData(asyncNotifyReq);

			orderAsyncNotifyCall.callService();

			Logger.verifyEquals("ok", orderAsyncNotifyCall.getReturnData(),
					"验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	//send_pay_deadline_to_timer 23			notify_order_not_pay 消息
	public void Tc_OrderAsyncNotify_002() {
		Logger.start(true, "订单超时未支付,通知提醒");

		try {
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLuxury(false);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			asyncNotifyReq.setBusinessType(23);

			asyncNotifyReq.setOrderId(orderId);

			orderAsyncNotifyCall.setData(asyncNotifyReq);

			orderAsyncNotifyCall.callService();

			Logger.verifyEquals("ok", orderAsyncNotifyCall.getReturnData(),
					"验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	//send_pay_deadline_to_timer 23			notify_order_not_pay 消息
	public void Tc_OrderAsyncNotify_003() {
		Logger.start(true, "订单超时未支付,砍价团订单不通知提醒");

		try {
			TradingServiceResp placeOrderResp = TradingPlaceOrderCallService
					.placeOrderWithLuxury(false);

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();

			asyncNotifyReq.setBusinessType(23);

			asyncNotifyReq.setOrderId(orderId);

			orderAsyncNotifyCall.setData(asyncNotifyReq);

			orderAsyncNotifyCall.callService();

			Logger.verifyEquals("ok", orderAsyncNotifyCall.getReturnData(),
					"验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}